function fig_distrib(s_grid, s_pdf, s_cdf, optfig, sd)

if optfig.plotfig == 1
    
    [fontname,~,lw,folder,color,~,~,~,~,fontsize_ax,fontsize_lab,~] = fn_optfig(optfig);
    
    if sd == 's'
        ylab_pdf = strcat('$f(',sd,')$');
        ylab_cdf = strcat('$F(',sd,')$');
        xlab = strcat('$',sd,'$');
        name = ['distrib_','s'];
    else
        ylab_pdf = strcat('$g(i)$');
        ylab_cdf = strcat('$G(i)$');
        xlab = strcat('$',sd,'$');
        name = ['distrib_','d'];
    end
    
    f1 = figure('Units','inches','Position',[0 0 16 6]);
    
    subplot(1,2,1)
    plot(s_grid,s_pdf,'Color',color{1},'LineWidth',lw);
    xlabel(xlab,    'interpreter','latex','FontSize',fontsize_lab,'FontName',fontname);
    ylabel(ylab_pdf,'interpreter','latex','FontSize',fontsize_lab,'FontName',fontname);
    title('pdf','interpreter','latex','FontSize',fontsize_lab,'FontName',fontname);
    grid; axis tight; box off;
    set(gca,'FontName', fontname, 'FontSize', fontsize_ax)
    ax = gca; ax.YAxis.Exponent = 0; % For decimals, to avoid scientific notation
    if sd == 'D_{0}(i)'
     xlim([0 max(s_grid)])
    end
    
    subplot(1,2,2)
    plot(s_grid,s_cdf,'Color',color{1},'LineWidth',lw)
    xlabel(xlab,    'interpreter','latex','FontSize',fontsize_lab,'FontName',fontname);
    ylabel(ylab_cdf,'interpreter','latex','FontSize',fontsize_lab,'FontName',fontname);
    title('cdf','interpreter','latex','FontSize',fontsize_lab,'FontName',fontname);
    grid; axis tight; box off;
    set(gca,'FontName', fontname, 'FontSize', fontsize_ax)
    ax = gca; ax.YAxis.Exponent = 0; % For decimals, to avoid scientific notation
    %xlim([s_min, s_max])
    ylim([0 1])
    
    print(f1,'-depsc','-painters','-noui','-r600',[folder,name,'.eps'])
    
    if optfig.close == 1; close(who('f')); end
    
end

end